import { JsonAsset } from "cc";
import AssetMgr from "../../../framework/asset/AssetMgr";
import SkillCfg from "./SkillCfg";
import { ResourceNames } from "../../constant/CommonConstant";

export default class SkillCfgRoot{
    private static _instance:SkillCfgRoot;
    public static get Ins():SkillCfgRoot{
        if(!this._instance){
            this._instance = new SkillCfgRoot();
            this._instance.init();
        }
        return this._instance;
    }
    cfgs:SkillCfg[] = [];
    //根据各种主键的集合
    cfgMap:Map<number,SkillCfg> = new Map();

    init(){
        let asset =AssetMgr.Ins.getBundleRes(ResourceNames.TableResources,"skill",JsonAsset)
        this.cfgs = asset.json as SkillCfg[]
        if(this.cfgs.length>0){
            this.cfgs.forEach(cfg=>{
                this.cfgMap.set(cfg.id,cfg)
            })
        }
    }
}